import java.util.Scanner;

public class Hw_02 {
    public static void main(String[] args) {
        //创建一个一维数组，最大的元素与第一个元素交换，最小的元素与最后一个元素交换，输出数组。

        int t;
        int max=0 , min = 0;
        int m, n;//m,n记录最大值最小值的位置
        Scanner input = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0; i < a.length; i++) {
            a[i] = input.nextInt();
            max = a[0];
            m = 0;
            min = a[0];
            n = 0;
            if (max <= a[i])
                max = a[i];
            if (min >= a[i])
                min = a[i];

        }

        for (int i = 0; i < a.length; i++) {
            if (max == a[i]) {
                m = i;
            }
            if (min == a[i]) {
                n = i;
            }
            t = a[0];
            a[0] = max;
            max = t;
            t = a[a.length - 1];
            a[a.length - 1] = min;
            min = t;
        }
        for (int i = 0; i < a.length; i++) {

            System.out.println(a[i]);

        }
    }
}
